导航菜单
首页 >  Setting up the files directory Installing Drupal 7 Drupal  > How to Install Drupal 7 on CentOS 7 With LEMP

How to Install Drupal 7 on CentOS 7 With LEMP

In a previous tutorial, I showed you how to install LEMP on CentOS 7 Server. Now If you want to build a website on top of that, you can either install WordPress or Drupal, both are good choice of content managemet system. This tutorial will show you how to install Drupal 7.

Install Drupal 7 on CentOS

First, upgrade all your system software to the lastest version available in your software repository using the following command:

sudo yum update

Next, download Drupal from the official website. You can use wget to do that:

wget http://ftp.drupal.org/files/projects/drupal-7.41.tar.gz

When you read this turorial, there maybe a newer version of drupal avaiable, you can check it at https://www.drupal.org/project/drupal

Once the download is completed, unpack it using the following command. This will create a drupal-7.41 directory under the current directory.

tar xzvf drupal-7.41.tar.gz

Now copy all the file in the drupal-7.41 directory to the web root. If you followed the previous tutorial, then your web root will be /usr/share/nginx/html

sudo mv drupal-7.41/* /usr/share/nginx/html/Setting up the database

Log into the MariaDB shell, this can be done using the command:

mysql -u root -p

Once you are in the MariaDB shell, create a new database for Drupal using the following command. I name it drupal, you can use whatever name you like.

create database drupal;

Then create a new database user using the following SQL statement. Again, I name it drupaluser, you can use whatever name you like.

create user drupaluser@localhost;

Set a password for the user:

set password for drupaluser@localhost= password("your-password");

Then grant all permission of the new database to the new user:

grant all privileges on drupal.* to drupaluser@localhost identified by 'your-password';

Flush your database:

flush privileges;

Exit MariaDB Shell:

exit;Configuring Drupal

Change your working directory to the web root:

cd /usr/share/nginx/html

Copy the default settings to a new file:

sudo cp sites/default/default.settings.php sites/default/settings.php

Add write permission to settings.php file and sites/default directory

sudo chmod a+w sites/default/settings.phpsudo chmod a+w sites/default

Last, we need to change the owner of web root directory to the Nginx user. The nginx user is usually nginx or www-data. You can check it in /etc/nignx/nginx.conf file In addtion, we need to add the current user to the www-data group, so that we can edit files under web root directory.

sudo chown nginx:nginx /usr/share/nginx/html/ -Rsudo usermod -a -G nginx your-usernamenewgrp nginxInstalling Drupal 7 in your browser

Before you go to your browser, we need to install php-gd so that the Drupal installation script can run without problems. This can be done using the command

sudo yum install php-gd php-xml php-mbstring

Edit /etc/php.ini file, put the following text to it.

extension=dom.so

Save the file and restart php-fpm

sudo systemctl restart php-fpm

Now head over to your web browser and type the following

http://server-domain or ip/install.php

You will see the Drupal installation wizard. Follow the instructions and finish the Drupal 7 installation.

After you installed Drupal, you should remove the index.html file in web root:

rm index.htmlRate this tutorial[Total: 2 Average: 4.5]

相关推荐: